package com.bit.springbook.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.Arrays;

@AllArgsConstructor
@NoArgsConstructor
public enum BookStatusEnum {
    INVALID(0, "无效"), // 无效 已经删除
    NORMAL(1, "可借阅"), // 正常 可以借阅
    FORBID(2, "不可借阅");// 禁止 不被借阅

    @Getter
    private Integer code;
    @Getter
    private String name;


    public static BookStatusEnum getStatusByCode(Integer code) {
        for (BookStatusEnum value : BookStatusEnum.values()) {
            if (value.code.equals(code)) {
                return value;
            }
        }
        return null;
    }
}
